﻿// This software is the confidential and proprietary information of NetBay.
// Such confidential information should not be disclosed.
// NetBay copyright(c) 2012

using System;
using System.Windows.Markup;

namespace Rio.Framework.Localisation
{
    public class ResxExtension : MarkupExtension
    {
        #region Properties

        public string ResxKey { get; set; }

        #endregion

        /// <summary>
        /// When implemented in a derived class, returns an object that is provided as the value of the target property for this markup extension.
        /// </summary>
        /// <param name="serviceProvider">A service provider helper that can provide services for the markup extension.</param>
        /// <returns>
        /// The object value to set on the property where the extension is applied.
        /// </returns>
        public override object ProvideValue(IServiceProvider serviceProvider)
        {
            return !String.IsNullOrWhiteSpace(ResxKey) ? Resx.GetLabel(ResxKey) : String.Empty;
        }
    }
}